package obj;
import json.JSONAble;
import org.json.me.*;
/**
 *
 * @author liemmaster
 */
public class MonHoc implements json.JSONAble
{
    int ID;
    String ten;
    int soHocTrinh;

    public int getID() {
        return ID;
    }

    public int getSoHocTrinh() {
        return soHocTrinh;
    }

    public String getTen() {
        return ten;
    }

    public void setID(int ID) {
        this.ID = ID;
    }

    public void setSoHocTrinh(int soHocTrinh) {
        this.soHocTrinh = soHocTrinh;
    }

    public void setTen(String ten) {
        this.ten = ten;
    }

    public MonHoc(int ID, String ten, int soHocTrinh) {
        this.ID = ID;
        this.ten = ten;
        this.soHocTrinh = soHocTrinh;
    }
    
    public MonHoc() {}

    public String toString() {
        return "MonHoc{" + "ID=" + ID + ", ten=" + ten + ", soHocTrinh=" + soHocTrinh + '}';
    }

    public void fromJSON(String jsonString) {
		try {
			JSONObject json = new JSONObject(jsonString);
                        setID(json.getInt("id"));
                        setTen(json.getString("ten"));
                        setSoHocTrinh(json.getInt("soHocTrinh"));
		} catch (JSONException ex) {
			ex.printStackTrace();
		}
	}
	public String toJSON() {
		JSONObject inner = new JSONObject();
		try {
			inner.put("id", getID());
			inner.put("ten", getTen());
			inner.put("soHocTrinh", getSoHocTrinh());
		} catch (JSONException ex) {
			ex.printStackTrace();
		}
		return inner.toString();
	}
    
}
